<template>
	<view id="voteIndex">

		<view class="vote-cont" v-for="(item,index) in voteData" style="padding: 10px 20px;">
			<view style="padding: 10px 20px;background: #fff; color: #999;" @click="navTo(item)">
				<view style="margin-top: 10px;"> 当前步骤：<text class="font_color">第{{item.vote_steps}}</text>
					<text class="font_color" v-if="item.vote_type == 1">
						{{item.vote_steps == 1 ? "基本信息"
						: item.vote_steps == 2 ? "发起首次申请" 
						: item.vote_steps == 3 ? "筹备组招募"
						: item.vote_steps == 4 ? "自定业主规约"
						: item.vote_steps == 5 ? "招募委员"
						: item.vote_steps == 6 ? "召开首次业主大会"
						: item.vote_steps == 7 ? "候选人投票"
						: item.vote_steps == 8 ? "业委会职务确认"
						: item.vote_steps == 9 ? "备案"
						: "未知"
						}}
					</text>
					<text class="font_color" v-if="item.vote_type == 2">
						{{ item.vote_steps == 1 ? '基本信息' 
						 : item.vote_steps == 2 ? '发起解聘申请' 
						 : item.vote_steps == 3 ? '召开业主大会方案' 
						 : item.vote_steps == 4 ? '发布大会通知'
						 : item.vote_steps == 5 ? '召开业主大会' 
						 : '备案' 
						 }}
					</text>
					<text class="font_color" v-if="item.vote_type == 3">
						{{ item.vote_steps == 1 ? '基本信息' 
						 : item.vote_steps == 2 ? '发起选聘申请' 
						 : item.vote_steps == 3 ? '进行决议' 
						 : item.vote_steps == 4 ? '决议结果'
						 : item.vote_steps == 5 ? '召开业主大会'
						 : '备案'
						 }}
					</text>
					<text v-if="item.redDotsTotal && item.redDotsTotal > 0" class="redDotsStyle"></text>
				</view>
				<view style="margin-top: 10px;">小区名称：
					<text class="font_color">{{item.community_name}}</text>
				</view>
				<view style="margin-top: 10px;">发布时间：
					<text class="font_color">{{item.begin_time}}</text>
				</view>
				<view style="margin-top: 10px;">发起人：
					<text class="font_color">{{item.full_name}}</text>
				</view>
			</view>
		</view>
		<view v-if="voteData.length ==0">
			<view style="width: 232px;height: 242px;margin: 0px auto;">
				<image style="width: 100%;height: 100%;margin-top: 106px;"
					src="@/static/image/9015d0e9f45344c4007d408cd271f6a.png" mode="">
				</image>
			</view>

			<view style="width: 79%;margin: 132px auto;text-align: center;color: #999;">暂无数据</view>
		</view>

		<uni-popup ref="popup" background-color="#fff" border-radius="8px">
			<view class="meeting-dialog">
				<image @click="closeFlag()" src="../../static/image/11.png"
					style="width: 25px;height: 25px;float: right;padding: 8px 5px 0 0;">
				</image>
				<view class="meeting-wrap">
					<view class="meeting-title">
						发起表决
					</view>
					<view class="meeting-start">
						目前暂不支持助业业主app直接发起投票表决功能，请到使用电脑登录助业网（www.515f.com)，或下载助业app进行发起。
					</view>
					<view class="meeting-btn" @click="goFy">
						下载助业app
					</view>
				</view>
			</view>
		</uni-popup>

		<view @click="toAdd" class="ware_flexd_add"></view>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				voteData: [],
				id: null,
				user_id: null,
				proId: null,
			}
		},
		async onShow() {
			let _this = this
			if (!uni.getStorageSync('phone') || !uni.getStorageSync('rawData')) {
				uni.showModal({
					title: '请先登录',
					showCancel: false,
					confirmText: '确认',
					confirmColor: '#F9A832',
					success: function(res) {
						if (res.confirm) {
							console.log('a')
							_this.$Router.pushTab({
								path: '/pages/user/user'
							})
						}
					}
				});
				return;
			}
			this.user_id = uni.getStorageSync('rawData').userId;
			this.getVoteList()
		},
		onPullDownRefresh() {
			let _this = this
			if (!uni.getStorageSync('phone') || !uni.getStorageSync('rawData')) {
				uni.showModal({
					title: '请先登录',
					showCancel: false,
					confirmText: '确认',
					confirmColor: '#F9A832',
					success: function(res) {
						if (res.confirm) {
							console.log('a')
							_this.$Router.pushTab({
								path: '/pages/user/user'
							})
						}
					}
				});
				return;
			}
			this.user_id = uni.getStorageSync('rawData').userId;
			this.getVoteList()
		},
		methods: {
			closeFlag() {
				this.$refs.popup.close()
			},
			goFy() {
				uni.navigateTo({
					url: '/pages/user/downApp'
				})
				this.$refs.popup.close()
			},
			toAdd() {
				this.$refs.popup.open()
			},
			getVoteList() {
				uni.showLoading({
					title: "加载中"
				})
				this.$requestYz.api.getVote({
					ownerApp: this.user_id,
				}).then(res => {
					this.voteData = res.data.data.datalist
					for (var i = 0; i < this.voteData.length; i++) {
						this.id = this.voteData[i].id
					}
					uni.hideLoading()
				})
				uni.stopPullDownRefresh()
			},
			navTo(item) {
				uni.navigateTo({
					url: '/pages/vote/voteIndex?id=' + item.id + '&vote_type=' + item.vote_type
				});
			},
		}
	}
</script>
<style lang='scss'>
	.meeting-dialog {
		position: relative;

		::v-deep .u-mode-center-box {
			width: 670rpx !important;
			height: 800rpx;
			background: #FFFFFF !important;
			border-radius: 8px;
			border-radius: 12rpx !important;
		}

		.meeting-wrap {
			padding: 40rpx;
			width: 700rpx;
			border-radius: 26rpx;
		}

		.meeting-title {
			text-align: center;
			font-size: 18px;
			font-weight: bold;
			padding-bottom: 13px;
			border-bottom: 1px solid #E7ECE1;
		}

		.meeting-start {
			margin: 40rpx 0 24rpx;
			font-size: 16px;
			font-weight: bold;
		}

		.meeting-cont {
			color: #333;
			font-size: 28rpx;
			border-bottom: 60rpx;
		}

		.meeting-btn {
			width: 350rpx;
			height: 88rpx;
			line-height: 88rpx;
			background: #FFFFFF;
			border-radius: 22px;
			border: 1px solid #427705;
			text-align: center;
			color: #427705;
			margin: 40px auto;
		}
	}

	.meeting-close {
		position: absolute;
		z-index: 999;
		margin-top: 370px;
		margin: 370px auto;
		left: 42%;
	}

	.meeting-close-btn {
		width: 80rpx;
		height: 80rpx;
	}

	.ware_flexd_add {
		width: 100rpx;
		height: 100rpx;
		position: fixed;
		bottom: 200rpx;
		right: 36rpx;
		background: url(../../static/image/tenAddDatas.png)no-repeat;
		background-size: 100%;
	}

	.redDotsStyle {
		width: 30rpx;
		height: 30rpx;
		line-height: 30rpx;
		background: red;
		border-radius: 50%;
		font-size: 24rpx;
		color: #fff;
		margin-left: 10px;
		position: absolute;
	}

	#voteIndex {
		background: #f4f4f4;
		height: 100vh;

		/*弹框*/
		.meeting-dialog {
			position: relative;

			::v-deep .u-mode-center-box {
				width: 670rpx !important;
				height: 800rpx;
				background: #FFFFFF !important;
				border-radius: 12rpx !important;
			}


			.meeting-wrap {
				padding: 40rpx;
			}

			.meeting-title {
				font-size: 18px;
				font-weight: bold;
				padding-bottom: 20px;
				border-bottom: 1px solid #E7ECE1;
			}

			.meeting-start {
				margin: 40rpx 0 24rpx;
				font-size: 16px;
				font-weight: bold;

				.img {
					width: 160px;
					height: 114px;
					margin: 0 auto;
					transform: translate(74px, 8px);
				}
			}

			.meeting-cont {
				color: red;
				font-size: 32rpx;
				border-bottom: 60rpx;
				margin-top: 50rpx;
				margin-bottom: 120rpx;
				text-align: center;
			}

			.succ {
				color: #333300;
				font-weight: bold;
			}

			.meeting-btn {
				width: 350rpx;
				height: 88rpx;
				line-height: 88rpx;
				background: #FFFFFF;
				border-radius: 22px;
				border: 1px solid #427705;
				text-align: center;
				color: #427705;
				margin: 5px auto;
				font-weight: bold;
			}
		}






		.vote-title {
			font-size: 36rpx;
			font-weight: bold;
			margin: 50rpx auto;
			text-align: center;
		}

		.vote-wrap {
			margin: 20rpx 30rpx;

			.vote-item {
				width: 700rpx;
				height: 300rpx;
				background: #FFFFFF;
				border-radius: 6px;

				.agree {
					color: #999;
					font-size: 24rpx;
					text-align: center;
					padding: 34rpx 8rpx;
				}

			}

			.person-num {
				text-align: center;
				font-size: 40rpx;
				font-weight: bold;
			}

			.person-assets {
				display: flex;
				justify-content: center;
				align-items: center;
				margin-top: 40rpx;
			}

			.person-txt {
				color: #999;
			}

			.person-number {
				font-weight: bold;
				font-size: 16px;
				margin-top: 8rpx;
			}

			.line {
				width: 1px;
				height: 48rpx;
				background: #eee;
				margin: 0 126rpx;
			}

			.vote-item1 {
				width: 700rpx;
				height: 160rpx;
				background: #FFFFFF;
				border-radius: 6px;
				margin-top: 40rpx;
				padding-top: 4rpx;
			}

			.vote-start {
				width: 570rpx;
				height: 88rpx;
				background: linear-gradient(180deg, #76D904 0%, #417505 100%);
				border-radius: 44rpx;
				text-align: center;
				line-height: 88rpx;
				color: #fff;
				margin: 60rpx auto;
			}

			.vote-bottom-txt {
				color: #999;
				font-size: 28rpx;
				text-align: center;
				font-weight: bold;
			}

		}
	}

	.my-tabs {
		height: 88upx;
		font-size: 28upx;
		display: flex;
		justify-content: space-around;
		box-sizing: border-box;
		border-top: 2upx solid #dddddd;
		border-bottom: 2upx solid #dddddd;
		min-width: 100%;
		overflow-x: auto;
		background: #fff;

		.tab-item {
			line-height: 48upx;
			padding: 20upx;
			min-width: 100upx;
			text-align: center;
		}

		.tab-item.active {
			position: relative;
			color: #427705;
		}

		.tab-item.active::after {
			content: "";
			position: absolute;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);
			width: 100%;
			border-bottom: 4upx solid #427705;
			animation: test ease 1 1.5s;
		}
	}

	.my-tabs.space-between {
		justify-content: space-between;
	}

	@keyframes test {
		0% {
			width: 100%
		}

		50% {
			width: 150%
		}

		100% {
			width: 100%
		}
	}

	.popup-all {
		background: #F5F5F5;
		padding: 13px 20px;
	}

	.share-detail {
		width: 17%;
		/* // height: 100rpx;
		// border: 2rpx solid #000; */
		padding: 13rpx;
		margin: 0rpx 0rpx 54rpx 40rpx;
		text-align: center;
	}

	.image-all {
		width: 100rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #FFFFFF;
		border-radius: 16rpx;
	}

	.image-all image {
		width: 74rpx;
		height: 74rpx;
	}

	.font {
		/* // border: 2rpx solid #000; */
		margin-top: 12rpx;
		font-size: 22rpx;
		font-weight: 400;
		color: #999999;

	}

	.fx {
		text-align: center;
		padding: 16rpx 0rpx 24rpx 0rpx;
		font-size: 26rpx;
		font-weight: 400;
		color: #999999;
	}

	.cancel {
		height: 114rpx;
		background: #FFFFFF;
		text-align: center;
		font-size: 36rpx;
		font-weight: 400;
		color: #333333;
		line-height: 114rpx;
	}

	.font_color {
		color: #333;
	}
</style>